package com.geekhalo.lego.core.query.support;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;


public class QueryServiceProxyFactoryBean<B>
        implements FactoryBean<B> {
    private final Class<B> queryService;

    @Autowired
    private QueryServiceProxyFactory queryServiceFactory;


    public QueryServiceProxyFactoryBean(Class queryService) {
        this.queryService = queryService;
    }

    @Override
    public B getObject() throws Exception {
        return this.queryServiceFactory.createQueryService(this.queryService);
    }

    @Override
    public Class<?> getObjectType() {
        return this.queryService;
    }
}
